import React from 'react'
// ===================================================================== Temp
import TableModal from '#cpt/temp/TableModal'
import TableControls from '#cpt/temp/TableControls'
// ===================================================================== global declare
const { $fn } = window

const specType = [{ name: "已审核", value: "1" },{ name: "待审核", value: "0" }, { name: "待保存", value: "-2" }]
// ===================================================================== component
class Index extends React.Component{
	state = {
		data:[],
	}
	
	model = {}
	
	open = rows => {
		const { uuid, spec_code  } = rows[0] || {} 
		this.modal.open()
		this.query = { spec_id:uuid, spec_code }
		// 阻止重复加载数据
		this.fetch()
	}
	
	// paging
	fetch = () => $fn.fetch.call(this, 'specimen-kind/index',{isIndex:true, paging:'get'})
	
	// 表单
	cols = [
		{ title: '项目代码', 	dataIndex: 'kind_code', 	width:150 },
		{ title: '项目名称', 	dataIndex: 'kind_name', 	width:150 },
		{ title: '项目状态', 	dataIndex: 'enabled', 	width:150,render:text=>$fn.getState(specType,text) },
		TableControls.controls.call(this)
	]
	
	// 表格操作按钮
	table_controls = (text,{ uuid }) => {
		return[
			TableControls.del.call(this, { param:{uuid}, api:'specimen-kind/end', refresh:true, onOk:()=>{
				if(!$fn.hasArray(this.state.data)){
					this.props?.onRefresh?.()
				}
			}})
		]
	}
	
	// 删除
	//onDel = uuid => Delete.call(this, 'specimen-kind/end', { uuid, isKeys: !uuid })
	
	render(){
		return TableModal.call(this,{ title: '项目作废', labelWidth:'s7', width:'60%', height:'80%', noSubmit:true, isIndex:true })
	}
}

export default Index